package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
 * @author Huangjin
 * @version 1.0
 * describe:使用转换流来读取文本数据
 * @date 2023/3/8 17:06
 */
public class ISRDemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("osw.txt");
        InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
        /*
            int read()
            读取一个字符(到底读取几个字节要根据他的内容以及对应的字符集决定)
            返回int值实际上是一个
         */
        int d = isr.read();
        while ((d= isr.read())!=-1){
            System.out.print((char) d);
        }
        System.out.println("读取完毕");
        isr.close();
    }
}
